package com.dean.others;

import com.dean.others.SimpleCalculate;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @ClassName OptionalOpt
 * @Description test
 * @Author dean
 * @Date 2021/12/27 10:52
 */
public class StreamOpt {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("hello");
        list.add("hh");
        list.add("world");
        list.add("wwwwww");
        String s1 = null;
        System.out.println(list.stream()
                // 筛选出长度 = 5
                .filter(i->i.length()==5)
                // 转换为大写
                .map(i-> i.toUpperCase())
                .collect(Collectors.joining(",")));

        Optional.ofNullable(s1).ifPresent(i->{
            System.out.println(i);
        });

    }
}
